<template>
    <div>
        <h1>新增专业</h1>
        <el-form :inline="true" :model="subjects" class="demo-form-inline">
   <label for="" class="sub">专业
        <input type="text" v-model="subjects.name"  class="sub2">
  </label>
  <el-form-item>
    <el-button type="primary" @click="onSubmit">确认添加</el-button>
  </el-form-item>
</el-form>
    </div>
</template>

<script>
import {createNamespacedHelpers} from 'vuex'
  const {mapActions}=  createNamespacedHelpers('subject') 
export default {
      data() {
            return {
                 subjects:{
                     
                 }
            }
        },
           methods: {
              ...mapActions(['addSubjectAsync']),
             async  addOne(){   
                       const data=await this.addSubjectAsync(this.subjects)
                         if(data.code){
                           this.$message({
                              message: '新增专业成功',
                              type: 'success'
                            });
                            this.$router.push('/home/subject')
                         }
               },
           async onSubmit() {
             this.addOne()
                
      },
        
    }
}
</script>

<style scoped>  
.sub{
    font-size: 20px;
}
.sub2{
    height: 23px;
    margin-right: 10px;
}
</style>